function [xvariable yvariable]=PrepareRegressX(price,retvet,resReturn)
try
vec_x=[];
[mat_XX window] = patternRec3(price(1:end-1,3));

% ADX indicator
[vout]=indicators(price(1:end-1,:),'adx',3);
mat_XX = [mat_XX vout(window:end,3)];
[vout]=indicators(price(1:end-1,:),'adx',14);
mat_XX = [mat_XX vout(window:end,3)];

% Stochastic Oscillator (Base on
[vout1]=indicators(price(1:end-1,:),'fsto',3,3);
mat_XX = [mat_XX vout1(window:end,:)];

[vout2]=indicators(price(1:end-1,:),'fsto',14,3);
mat_XX = [mat_XX vout2(window:end,:)];
mat_XX = [mat_XX vout1(window:end,:)./vout2(window:end,:)];

% momentum (rate of change)
[vout1]=indicators(price(1:end-1,3),'roc',3);
mat_XX = [mat_XX vout1(window:end)];

[vout2]=indicators(price(1:end-1,3),'roc',14);
mat_XX = [mat_XX vout2(window:end)];

mat_XX = [mat_XX vout1(window:end)./vout2(window:end)];


% relative strength index

[vout1]=indicators(price(1:end-1,3),'rsi',3);
mat_XX = [mat_XX vout1(window:end)];

[vout2]=indicators(price(1:end-1,3),'rsi',14);
mat_XX = [mat_XX vout2(window:end)];

mat_XX = [mat_XX vout1(window:end)./vout2(window:end)];


% macd
[vout1]=indicators(price(1:end-1,3),'macd');
mat_XX = [mat_XX vout1(window:end,:)];

%average true range
[vout1]=indicators(price(1:end-1,:),'atr',3);
mat_XX = [mat_XX vout1(window:end)];

[vout2]=indicators(price(1:end-1,:),'atr',14);
mat_XX = [mat_XX vout2(window:end)];
mat_XX = [mat_XX vout1(window:end)./vout2(window:end)];


% simple moving average

[vout1]=indicators(price(1:end-1,3),'sma',3);
mat_XX = [mat_XX vout1(window:end)];

[vout2]=indicators(price(1:end-1,3),'sma',14);
mat_XX = [mat_XX vout2(window:end)];
mat_XX = [mat_XX vout1(window:end)./vout2(window:end)];
vout1=[];vout2=[];
catch
    mat_XX=[];
end
% Calculate real residual
ttt=length(retvet(:,1));
if window>ttt   %This is to prevent the case of revet vector length lower than the window
    window=ttt;
end
% if i==length(firstprice(:,2))
%     YFIT(pos(i)+window:end)=YFIT(pos(i)+window:end)-retvet(window+1:end,4);
    %         zz(i,2)=length(YFIT(pos(i)+window:end));
% else
try
    resReturn(1+window:end)=resReturn(1+window:end)-retvet(window+1:end,4);
catch
    resReturn(1+window:end)=resReturn(1+window:end)-retvet(window+1:end,4)';
end
    %         zz(i,2)=length(pos(i)+window:pos(i+1)-1);
% Remove window part
%      qua dai dong doan nay/
if size(mat_XX,2)==33;
    vec_x=[vec_x;mat_XX];
    resReturn(1:window-1)=[];
else
    resReturn(1:end)=[];
    %         zz(i,1)=size(vec_x,1);-+
end
xvariable=vec_x;
yvariable=resReturn;
